package com.jz.netthings.system.mapper.mysql;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.jz.netthings.bean.system.JyMenu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * <p>
 * 系统菜单表 Mapper 接口
 * </p>
 *
 * @author yyy
 * @since 2018-08-01
 */
public interface JyMenuMapper extends BaseMapper<JyMenu> {

    @Select("SELECT m.* FROM jy_menu m LEFT JOIN (SELECT menu_id FROM role_menu WHERE role_id = #{roleId}) temp on m.id = temp.menu_id WHERE temp.menu_id is not null")/*  and m.srcType = 2*/
    List<JyMenu> selectMenusByRole(@Param("roleId") Integer roleId);


    @Select("SELECT menu_id FROM role_menu WHERE role_id = #{roleId}")
    List<Integer> selectRolesMenuIds(@Param("roleId") Integer roleId);

    @Select("SELECT count(*) from jy_menu where parentId = #{parentId}")
    int selectByParentCount(@Param("parentId") Integer parentId);

}
